package br.inf.prismasoft.academix.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.hibernate.validator.NotNull;

/**
 * Falta generated by hbm2java
 */
@Entity
@Table(name = "FALTA", schema= "ACADEMIX", uniqueConstraints = @UniqueConstraint(columnNames = {
		"ind_turma", "ind_disciplina", "dat_falta" }))
public class Falta implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 359453633086731120L;
	private int idtFalta;
	private Disciplina disciplina;
	private Turma turma;
	private Date datFalta;
	private Set<FaltaItem> faltaItems = new HashSet<FaltaItem>(0);

	public Falta() {
	}

	public Falta(int idtFalta, Disciplina disciplina, Turma turma, Date datFalta) {
		this.idtFalta = idtFalta;
		this.disciplina = disciplina;
		this.turma = turma;
		this.datFalta = datFalta;
	}

	public Falta(int idtFalta, Disciplina disciplina, Turma turma,
			Date datFalta, Set<FaltaItem> faltaItems) {
		this.idtFalta = idtFalta;
		this.disciplina = disciplina;
		this.turma = turma;
		this.datFalta = datFalta;
		this.faltaItems = faltaItems;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idt_falta", unique = true, nullable = false)
	public int getIdtFalta() {
		return this.idtFalta;
	}

	public void setIdtFalta(int idtFalta) {
		this.idtFalta = idtFalta;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ind_disciplina", nullable = false)
	@NotNull
	public Disciplina getDisciplina() {
		return this.disciplina;
	}

	public void setDisciplina(Disciplina disciplina) {
		this.disciplina = disciplina;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ind_turma", nullable = false)
	@NotNull
	public Turma getTurma() {
		return this.turma;
	}

	public void setTurma(Turma turma) {
		this.turma = turma;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "dat_falta", nullable = false, length = 10)
	@NotNull
	public Date getDatFalta() {
		return this.datFalta;
	}

	public void setDatFalta(Date datFalta) {
		this.datFalta = datFalta;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "falta")
	public Set<FaltaItem> getFaltaItems() {
		return this.faltaItems;
	}

	public void setFaltaItems(Set<FaltaItem> faltaItems) {
		this.faltaItems = faltaItems;
	}

}
